<?php
//menu
echo "
	<div style='display:block; text-align:right; float:right;'>
		<div class='menu_messages_active'><a href='/messages/compose'>" . Language::Get('Compose') . "</a></div> 	
		<div class='menu_messages'><a href='/messages/inbox'>" . Language::Get('Inbox') . "</a></div> 
		<div class='menu_messages'><a href='/messages/outbox'>" . Language::Get('Outbox') . "</a></div>
	</div>"; 

//compose form
echo "
	<div class='pageHeading'>Compose new message</div>
	<div style='display:block; clear:both;'>";
		XHTML::Form('/messages/create', 'POST', 'id="submitForm"');
echo "	<table cellspacing='0' cellpadding='4' border='0' width='100%'>";

//Topic
echo "		<tr>
	        	<td width=30%><span class='composeForm'>".Language::Get('Topic').":</span></td>
	            <td class='dq-input-text'>
	            	<table cellspacing='0' cellpadding='0' border='0' width='100%'>
	            		<tr>
							<td class='inputType-1-left'></td>
							<td class='inputType-1-center'>";
								XHTML::InputText('topic', '', 'id="topic"');
echo "						</td>
							<td class='inputType-1-right'></td>
						</tr>
					</table>";
	            	
	echo "	    </td>
	        </tr>";
	
//Recepient
echo "		<tr>
	        	<td><span class='composeForm'>".Language::Get('Recepient')." (" . Language::Get('Reference number') . "):</span></td>
	            <td class='dq-input-text'>
	            	<table cellspacing='0' cellpadding='0' border='0' width='100%'>
	            		<tr>
							<td class='inputType-1-left'></td>
							<td class='inputType-1-center'>";
								XHTML::InputText('recepient', HTTPContext::$get['recepient'], 'id="recepient" maxlength=13');
echo "						</td>
							<td class='inputType-1-right'></td>
						</tr>
					</table>";
	            	
	echo "	    </td>
	        </tr>";
	
//Text
echo "		<tr>
	        	<td><span class='composeForm'>".Language::Get('Text').":</span></td>
	            <td class='dq-input-text'>";
	            	XHTML::Textarea('text', '', 'style="width: 100%; height: 100px;" id="text"');
	            	
	echo "	    </td>
	        </tr>";
echo "</table></form>

<table cellspacing='0' cellpadding='0' border='0'>
	<tr>
		<td class='btnType-5-left btnType-5-left-select'></td>
		<td class='btnType-5-center btnType-5-center-select' align='center'>
			<span class='btnType-5-txt cpointer' onclick='BeforeSubmit()'>".Language::Get('Send')."</span>
		</td>
		<td class='btnType-5-right btnType-5-right-select'></td>
	</tr>
</table>

	</div>";

XHTML::Script("", "
	function BeforeSubmit()
	{
		if ($('#topic').val() == '' || $('#recepient').val() == '' || $('#text').val() == '')
		{
			alert('Fill all the fields first!');
		}
		else if (isNaN(parseFloat($('#recepient').val())) || $('#recepient').val().length < 13)
		{
			alert('Enter correct recepient reference number!');
		}
		else
		{
			$('#submitForm').submit();
		}
	}
");
?>